;;;
// mymymymymymymymymymymymymymymymymymy
var banp =document.querySelector('.banp')
console.log(banp);
var ban =document.querySelector('.ban')
console.log(ban);
var guild =document.querySelector('#guild')
//课程分类
var guib =guild.querySelector('.guib')
//在线测试
var guib1 =document.querySelector('.guib1')
console.log(guib1);
//精品课程
var guib3=document.querySelector('.guib3')
console.log(guib3);
// 轮播图
var bannerData = [{
  title: '24小时不断电大课堂',
  src: './img1/index/tbanner1.png'
},
{
  title: '毕胜技能',
  src: './img1/index/tbanner2.png'
},
{
  title: '更多锻炼',
  src: './img1/index/tbanner3.png'
},
{
  title: '直播公开课',
  src: './img1/index/tbanner4.png'
},
{
  title: '线上狂欢',
  src: './img1/index/tbanner5.png'
}
];
banp.innerHTML = bannerData.map(function (item) {
  return `
      <li>
        
              <img src="${item.src}" alt="查无此图">
         
      </li>
      `
}).join("")
// 轮播图中的导航
ban.innerHTML = bannerData.map(function (item) {
  return `
      <li>
        
          ${item.title}   
         
      </li>
      `
}).join("")

//同步课程数据
var lesson = {
  online: [{
      title: '行政管理专业班1',
      src: './img1/index/banner1.png',
      cont: '人教版',
      time: 23,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班2',
      src: './img1/index/banner2.png',
      cont: '人教版',
      time: 23,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班3',
      src: './img1/index/banner3.png',
      cont: '人教版',
      time: 23,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班4',
      src: './img1/index/banner4.png',
      cont: '人教版',
      time: 22,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班5',
      src: './img1/index/banner5.png',
      cont: '人教版',
      time: 33,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班7',
      src: './img1/index/banner7.png',
      cont: '人教版',
      time: 44,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班6',
      src: './img1/index/banner6.png',
      cont: '人教版',
      time: 33,
      isFree: true,
      num: 1100
  }, {
      title: '行政管理专业班8',
      src: './img1/index/banner8.png',
      cont: '人教版',
      time: 44,
      isFree: true,
      num: 1100
  }],
  test: [{
          title: '2020年6月北京中考试题',
          src: './img1/index/test1.png',
          cont: '北京',
          time: '初一',
          num: 1100
      },
      {
          title: '2020年6月北京中考试题',
          src: './img1/index/test2.png',
          cont: '北京',
          time: '初一',
          num: 1100
      }, {
          title: '2020年6月北京中考试题',
          src: './img1/index/test3.png',
          cont: '北京',
          time: '初一',
          num: 1100
      }, {
          title: '2020年6月北京中考试题',
          src: './img1/index/test4.png',
          cont: '北京',
          time: '初一',
          num: 1100
      }, {
          title: '2020年6月北京中考试题',
          src: './img1/index/test5.png',
          cont: '北京',
          time: '初一',
          num: 1100
      }, {
          title: '2020年6月北京中考试题',
          src: './img1/index/test6.png',
          cont: '北京',
          time: '初一',
          num: 1100
      }
  ],
  good: [
      {
          title: '行政管理专业班',
          src: './img1/index/good_banner1.png',
          cont: '天津',
          time: 23,
          isFree: true,
          num: 1100
      },{
          title: '行政管理专业班2',
          src: './img1/index/good_banner2.png',
          cont: '天津',
          time: 23,
          isFree: true,
          num: 1100
      },{
          title: '行政管理专业班3',
          src: './img1/index/good_banner3.png',
          cont: '天津',
          time: 23,
          isFree: true,
          num: 1100
      },{
          title: '行政管理专业班4',
          src: './img1/index/good_banner4.png',
          cont: '天津',
          time: 23,
          isFree: true,
          num: 1100
      },{
          title: '行政管理专业班5',
          src: './img1/index/good_banner5.png',
          cont: '天津',
          time: 23,
          isFree: true,
          num: 1100
      },{
          title: '行政管理专业班6',
          src: './img1/index/good_banner6.png',
          cont: '天津',
          time: 23,
          isFree: true,
          num: 1100
      }
  ]
  }
// 课程分类
guib.innerHTML =  lesson.online.map(function(item){
  return `
  <li>
                <img src="${item.src}" alt="">
                <div class="guib0">
                    <span>${item.cont}</span>
                    <span>${item.num}正在学习</span>
                </div>
                <div class="guib1">
                    <p class="guib1a">
                        <span>${item.title}</span><br>
                        <span class="guibaa">${item.time}课时</span>
                    </p>
                    <a href="./views/Videodetails.html"><div>免费学习</div></a>
                </div>
            </li>
`
}).join("")
// console.log('-----------在线测试------------');
guib1.innerHTML = lesson.test.map(function(item){
  return `
   <li>
            <img src="${item.src}" alt="">
                <div class="guib0">
                  
                    <span>${item.cont}</span>
                    
                  
                    <p>
                        <span>${item.time}</span>
                        <span> ${item.num}人已考试</span>
                    </p>
                </div>
                <div class="guib1">
                    <p class="guib1a">
                        <span> ${item.title}</span><br>
                        <span class="guibaa">23课时</span>
                    </p>
                    <div>去考试</div>
                </div>
            </li>
  `
}).join("")
guib3.innerHTML = lesson.test.map(function(item){
    return `
    <li>
                <img src="${item.src}" alt="">
                <div class="guib0">
                    <span>${item.cont}</span>
                      <p>
                        <span>初一</span>
                        <span>${item.num}人已考试</span>
                    </p>
                </div>
                <div class="guib1">
                    <p class="guib1a">
                        <span> ${item.title}</span><br>
                        <span class="guibaa"> ${item.time}课时</span>
                    </p>
                    <a href="./views/Videodetails.html"><div>免费学习</div></a>
                </div>
            </li>
    `
  }).join("")



console.log(ban);
var oli =document.querySelectorAll('.banp li')
console.log(oli);
var pli = document.querySelectorAll('.ban li')
console.log(pli);
var timer = null
console.log(Y.opacity);
// 自运转
timer = setInterval(auto,2000)
var n = 0
function auto(){
    // 设定自运转一轮次数
      n++
      if(n>oli.length-1){
          n=0
        }
// 正式运转总
      change()

}
function change(){

    //先所有透明度为0
   for (var i = 0; i < oli.length; i++) {
    Y.opacity(oli[i],'opacity',0)
    pli[i].style.backgroundColor='rgba(37, 43, 117, 0)'
      }
      //正式运转
    Y.opacity(oli[n],'opacity',1)
    pli[n].style.backgroundColor='rgba(37, 43, 117, .8)'
}
//添加鼠标划上事件
for (let k = 0; k < pli.length; k++) {
     (function(k){
        pli[k].onmouseover=function(){
            n = k
            change()
        }
     })(k)
    
}

















//判断是否为登录状态
console.log(localStorage.isLogin);
var he =document.querySelector('.he')
console.log(he);
var img =document.querySelector('.img')
console.log(img);//头像
var ls =document.querySelector('.hea3 p')
console.log(ls);//登录注册
var hea3a =document.querySelector('.hea3a')
console.log(hea3a);
if(localStorage.isLogin=="true"){ //登录了
    // img.src = localStorage.logo
    he.style.display='block'
    ls.style.display='none'
}else{
    //隐藏头像
    he.style.display = 'none'
    ls.style.display='inline-block'
}
// 显示列表
img.onmouseover=function(){
hea3a.style.display='block'
}
document.onclick=function(){
    hea3a.style.display='none'
    }
//退出登录
    var tui = document.querySelectorAll('.hea3a li')
    console.log(tui);
    tui[tui.length-1].onclick=function(){
        localStorage.removeItem('isLogin')
         //隐藏头像
         he.style.display = 'none'
         ls.style.display='inline-block'
     }